<?php
/**
 * alltosun.com 设备号管理
 * ============================================================================
 * 版权所有 (C) 2009-2011 北京互动阳光科技有限公司，并保留所有权利。
 * 网站地址: http://www.alltosun.com
 * ----------------------------------------------------------------------------
 * 许可声明：这是一个开源程序，未经许可不得将本软件的整体或任何部分用于商业用途及再发布。
 * ============================================================================
 * $Author: 高昂 (gaoa@alltosun.com) $
 * $Date: 2016-4-25 上午11:38:58 $
 * $Id: $
 */

class Action
{
    public function index()
    {
        $page          = Request::Get('page_no', 1);
        $status        = Request::getParam('status', -1);
        $type      = Request::getParam('type', 'device');
        $search_filter = Request::getParam('search_filter', array());

        // 拼装搜索条件
        $is_empty = 0;
        $filter = array();

        if (isset($search_filter['id']) && $search_filter['id']) {
            $filter['id'] = $search_filter['id'];
        }

        if (isset($search_filter['device_no']) && $search_filter['device_no']) {
            $type = device_helper::get_device_type_by_code($search_filter['device_no']);
            $filter['code'] = $search_filter['device_no'];
        }
            $filter['type'] = $type;
        if (-1 != $status) {
            $filter['status'] = $status;
        } else {
            $filter['status'] = array(0, 1, 2, 3);
        }

        $device_list = array();
        $device_list = get_data_list('device', $filter, 'ORDER BY id DESC', $page);
        if ($device_list) {
            foreach ($device_list as $k => $v) {
                $device_list[$k]['device_no'] = $v['code'];
            }
        }


        Response::assign('device_list', $device_list);
        Response::assign('status', $status);
        Response::assign('type', $type);
        Response::assign('search_filter', $search_filter);

        Response::display('admin/device_list.html');
    }
}


?>